package com.shujia.scala

object Demo22Map {
  def main(args: Array[String]): Unit = {
    //每个元素是一个二元组
    val user: Map[String, Any] = Map("name" -> "张三", "age" -> 23, ("sex", "男"))

    println(user)

    //通过key获取value
    println(user.get("name"))

    //循环Map
    user
      .foreach((kv: (String, Any)) => {
        val key: String = kv._1
        val value: Any = kv._2
        println(s"$key\t$value")
      })

    for (kv <- user) {
      val key: String = kv._1
      val value: Any = kv._2
      println(s"$key\t$value")
    }
  }
}
